"""
中信接口测试
"""
import os
import sys
import django

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.extend([BASE_DIR, ])
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "finance_c2c.settings")
django.setup()

from core.zhongxin.client import ZXClient
from core.zhongxin.models import OrderRecord

if __name__ == '__main__':
    params, response = ZXClient().download_order("20200918")
    msgAnnex = response.get("msgAnnex")
    record = msgAnnex.get("record")
    o_s = []
    num = 0
    for i in record:
        orders = i.get("record").replace(" ", "")
        # o_num = orders[orders.find("           |") + len("           |"):orders.find("               |")]
        # if o_num.find('200806205734943156100') != -1:
        #     pass
        # else:
        #     o_s.append(o_num)
        num += 1
        print(orders, num)
        # print(orders)
        # params, response = ZXClient().refund_order("20062917191332217290", "2020-06-29 17:19:13", "9755", "01")
        # print(params)
        # print(response)

        # message, sign = {'payCode': 'KLB',
        #                  'retMsg': '订单已存在，且为系统异常'}, "HlCNpMBkb1qPR74hj2IxTlU5mqlFvdvMPhlaShs1hVHofOs8X/X3m/iXUyOZ14RfXEEfpRMV9gQCvrjtK67iY52LQi5bFj89IjiSAmiIKuq3VIh9mgmKjuvLNnL5nSbFnd1oh/JCf6Njl5MX3Vz9hR2MnATK3vGnQPtLXlkeAfNhVY8pTx5k//qg3IiayufkK1Yg52eSfriWWQyKLqPG+vWqtrWGf1vtDyqQg0svv+0ZXhKLx0RRWIGWT/jxj1lzOXtrjVs0cHKlHyurUZ1ennEz9Kw8KCb40LfxI9uKjnFYU1YMLmWh8U67ZHKKY/X4HYfuf1MXr4nq8srS4EBaUw=="
        # a = ZXClient().verify_with_rsa(message, sign)
        # print(a)
        # for i in o_s:
        #     if not OrderRecord.objects.filter(out_trade_no=i).exists():
        #         print(i)
